package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.LotMtlRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.MOSDetAddRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.OMtlWatiRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.OMtlwaitAddRequest;
import com.alks.function.service.stockdept.pcfactorystockquery.IMtlOutSurpService;
import com.alks.function.service.stockdept.pcfactorystockquery.IPcOtherMtlOutService;
import com.alks.function.service.stockdept.pcfactorystockquery.IPcSurplusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-剩料出库作业")
@RequiredArgsConstructor
@RoleCheck(prgIds = {"160114"})
public class MtlOutSurpController {
    private final IMtlOutSurpService service;
    private final IPcSurplusService surService;
    private final IPcOtherMtlOutService outService;

    @GetMapping("/getMOSTempQuery")
    @ApiOperation(value = "剩料出库作业-待出剩料明细-查询",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo getMOSTempQuery(){
        return service.getMOSTempQuery();
    }

    @PutMapping("/getMOSLotMtlQuery")
    @ApiOperation(value = "剩料出库作业-指令/贴合子材料-分页可条件查询",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo getMOSLotMtlQuery(@RequestBody LotMtlRequest request,
                                          @RequestParam@ApiParam("3.指令材料 4.贴合子材料") Integer type) {
        return surService.getLotMtlQuery(request, type);
    }

    @PostMapping("/getMOSSubMtlQuery")
    @ApiOperation(value = "剩料出库作业-贴合子材料明细-条件查询", tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo getMTSSubMtlQuery(@RequestParam String mtlNo) {
        return outService.otherLotSubMtlQuery2(mtlNo);
    }


    @PostMapping("/mOSTempUpdate")
    @ApiOperation(value = "剩料出库作业-待出明细更新-更新",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo mOSTempUpdate(@RequestParam@ApiParam("材料号") String mtlNo,
                                      @RequestParam(required = false)@ApiParam("材料号") Float qty,
                                      @RequestParam(required = false)@ApiParam("材料号") String remark){
        return service.mOSTempUpdate(mtlNo,qty,remark);
    }

    @PutMapping("/mOSTempAdd")
    @ApiOperation(value = "剩料出库作业-转入待出库剩料-新增",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo mOSTempAdd(@RequestBody List<OMtlwaitAddRequest> request,
                                   @RequestParam@ApiParam("1.库存 2.指令") Integer type){
        return service.mOSTempAdd(request,type);
    }

    @PutMapping("/getMOSDetailQuery")
    @ApiOperation(value = "剩料出库作业-待出库剩料查询-可条件查询",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo getMOSDetailQuery(@RequestBody OMtlWatiRequest request){
        return service.getMOSDetailQuery(request);
    }

    @PutMapping("/mOSDetailAdd")
    @ApiOperation(value = "剩料出库作业-出库批处理-新增",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo mOSDetailAdd(@RequestBody MOSDetAddRequest request){
        return service.mOSDetailAdd(request);
    }

    @PostMapping("/mOSTempDelete")
    @ApiOperation(value = "剩料出库作业-待出库明细删除-删除",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo mOSTempDelete(@RequestParam@ApiParam("材料号") String mtlNo){
        return service.mOSTempDelete(mtlNo);
    }

    @PostMapping("/mOSDetailDelete")
    @ApiOperation(value = "剩料出库作业-出库明细删除-删除",tags = "仓储部-仓储工厂作业-剩料出库作业")
    public ResponseInfo mOSDetailDelete(@RequestParam@ApiParam("材料号") String mtlNo,
                                      @RequestParam@ApiParam("出库单号") String slipNo){
        return service.mOSDetailDelete(mtlNo,slipNo);
    }
}
